<?
// Navi
$linkarray=$content->orderby('position')->contmedlinks->as_array();

if(! isset($maxw)){
	$maxw=$content->var1;
}

if(! isset($maxh)){
	$maxh=$content->var2;
}

if($maxw==''){
	$maxw=800;
}
if($maxh==''){
	$maxh=300;
}

if(count($linkarray)==0){
	return;
}

$selectedind=0;
$count=0;

$urlarray=array();

foreach ($linkarray as $link){
	$media=$link->media;
	$urlarray[]='"'.url::base().$media->get_resized_url($maxw,$maxh).'"';
	$isselected=($link->id==$this->id3);
	if($isselected){
		$selectedind=$count;
	}
	$count++;
}
?>

<script type="text/javascript">
medcontobj[<?=$content->id?>]=new Object();
medcontobj[<?=$content->id?>].urlarray=new Array(<?=implode($urlarray,',')?>);
medcontobj[<?=$content->id?>].selectedind=0;
</script>


<?
$nextind=$selectedind+1;
if($nextind>count($linkarray)-1){
	$nextind=0;
}

echo '<div class="mediacontainer_js" content_id="'.$content->id.'">';
echo '<div class="mediabig" style="height:'.$maxh.'px;" >';
$link=$linkarray[$selectedind];
$nextlink=$linkarray[$nextind];
$mediabig=$link->media;
$url=$link->media->get_resized_url($maxw,$maxh);
$href=$this->id.'/'.$this->id2.'/'.$nextlink->id;
echo html::anchor($href,html::image($url),array('objid'=>$content->id));
echo '</div>';
if(count($linkarray)>1){
	echo '<div class="medianavi">';
	$count=0;
	foreach($linkarray as $link){
		$naviclass='';
		$overlay='';	
		if($selectedind==$count){
			$naviclass='selected';
		}
		
		$media=$link->media;
		echo'<div class="medianavi_elm">';	
		$bigurl=url::base().$media->get_resized_url($maxw,$maxh);
		
		echo html::anchor($this->id.'/'.$this->id2.'/'.$link->id,($count+1), array('class'=>$naviclass, 'index'=>$count, 'objid'=>$content->id));
		echo '</div>';
		$count++;
	}	
	echo '</div>';
}

echo '<div class="clear"></div>';
echo '</div>';

?>